﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;
using Cvk.News;

namespace BatDongSan.Manager
{
    public partial class Manager : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["mrvuManager"] == null || Request.Cookies["mrvuManager"]["Username"] == null)
            {
                Response.Redirect("~/manager/LoginSystem.aspx");
            }
            lbUser.Text = Request.Cookies["mrvuManager"]["Username"].ToString();
            if (!IsPostBack)
            {
                LoadNewsTypes();
                //LoadCat();
            }
        }
        
        protected void lnkbtExit_Click(object sender, EventArgs e)
        {
            if (Request.Cookies["mrvuManager"] != null)
            {
                HttpCookie myCookie = new HttpCookie("mrvuManager");
                myCookie.Expires = DateTime.Now.AddDays(-1d);
                Response.Cookies.Add(myCookie);
                Response.Redirect(Request.RawUrl);
            }
        }
        public void LoadNewsTypes()
        {
            try
            {
                List<VG_NewsType> list = NewsBll.claNewsTypeDetail.GetListParent(1, Utility.strConnect);
                if (list.Count > 0)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        VG_NewsType module = list[i];

                        if (list[i].ParentId == 0) //Nếu idparent=0 thì in Hoa tòan bộ chữ
                        {
                            //ltrNewsType.Text += "<h3>" + list[i].TypeName + "</h3>";
                            ltrNewsType.Text += string.Format("<li><a href=\"/Manager/ManNews.aspx?idt={0}\" style=\"color:red; font-size:10px; font-weight:bold\">{1}</a></li>", list[i].NewsTypeId, list[i].TypeName.ToUpper());
                            List<VG_NewsType> list_sub = NewsBll.claNewsTypeDetail.GetListByParentId(1, list[i].NewsTypeId, Utility.strConnect);
                            if (list_sub.Count > 0)
                            {
                                //ltrNewsType.Text += "<ul class=\"nav\">";
                                for (int j = 0; j < list_sub.Count; j++)
                                {
                                    ltrNewsType.Text += string.Format("<li><a href=\"/Manager/ManNews.aspx?idt={0}\">{1}</a></li>", list_sub[j].NewsTypeId, list_sub[j].TypeName);
                                }
                                //ltrNewsType.Text += "</ul>";
                            }
                        }
                    }
                }
            }
            catch { }
        }
        //public void LoadCat()
        //{
        //    try
        //    {
        //        List<Cvk_Category> list = CategoryBll.GetListByParentId(0, Utility.strConnect);
        //        if (list.Count > 0)
        //        {
        //            for (int i = 0; i < list.Count; i++)
        //            {
        //                Cvk_Category module = list[i];

        //                if (list[i].ParentId == 0) //Nếu idparent=0 thì in Hoa tòan bộ chữ
        //                {
        //                    //ltrNewsType.Text += "<h3>" + list[i].TypeName + "</h3>";
        //                    ltrListCate.Text += string.Format("<li><a href=\"javascript:void()\" style=\"color:red; font-size:10px; font-weight:bold\">{0}</a></li>", list[i].Name.ToUpper());
        //                    List<Cvk_Category> list_sub = CategoryBll.GetListByParentId(list[i].CategoryId, Utility.strConnect);
        //                    if (list_sub.Count > 0)
        //                    {
        //                        //ltrNewsType.Text += "<ul class=\"nav\">";
        //                        for (int j = 0; j < list_sub.Count; j++)
        //                        {
        //                            ltrListCate.Text += string.Format("<li><a href=\"/Manager/ManProducts.aspx?idt={0}\">{1}</a></li>", list_sub[j].CategoryId, list_sub[j].Name);
        //                        }
        //                        //ltrNewsType.Text += "</ul>";
        //                    }
        //                }
        //            }
        //        }
        //    }
        //    catch { }
        //}
    }
}
